#!/bin/sh

# simplified certificate generation and installation for one Syracuse server
# takes the passphrase of the CA and of the server as arguments

# passphrases 
if [ $# -ne 2 ] ; then
        echo "Usage: $0 CA_PASSPHRASE SERVER_PASSPHRASE"
        exit 1
fi


# passphrase of CA (user input, parameter)
PASS_CA='$1'
# passphrase of server (user input, parameter)
PASS_SERVER='$2'

# certificate data
# country (user input)
C='${syracuse.certificate.countrycode}'
# state (user input)
ST='${syracuse.certificate.state}'
# city (user input)
L='${syracuse.certificate.city}'
# organization (user input)
O='${syracuse.certificate.organization}'
# organisational unit (user input)
OU='${syracuse.certificate.organisationalunit}'
# name (user input)
CN='${syracuse.certificate.name}'
# days of validity (user input)
DAYS='${syracuse.certificate.validity}'

# Name of server as used for TCP connections (optional user input)
TCP='${syracuse.certificate.hostname}'

# directories
# directory for certificate tool (user input)
TOOLDIR="${syracuse.certificate.certtool}"
# install cert for X3 runtime (optional user input)
X3INSTALL="${syracuse.certificate.setx3runtime}"
# directory for X3 runtime (optional user input)
X3DIR="${syracuse.certificate.x3runtime}"
# install cert for X3 runtime (optional user input)
X3INSTALLWEB="${syracuse.certificate.setx3webserver}"
# directory for X3 runtime (optional user input)
X3DIRWEB="${syracuse.certificate.x3webserverdata}"
# main path of Syracuse installation (given by setup)
# SYRACUSE_PATH=${INSTALL_PATH}/syracuse
SYRACUSE_PATH="${INSTALL_PATH}/syracuse"
# binpath of Syracuse installation (given by setup)
# BIN_PATH=${INSTALL_PATH}/syracuse/${syracuse.dir.binpath}
BIN_PATH="${INSTALL_PATH}/syracuse/${syracuse.dir.binpath}"
# certificate directory of Syracuse installation, without hostname (given by setup)
CERTDIR="${syracuse.dir.certs}"
NODEPATH="${nodejs.dir.binpath}"

# get hostname
HOST=`hostname`

# default TCP name is hostname
if [ "$TCP" = "" ] ; then
	TCP=$HOST
fi

# convert hostname to lowercase
HOST="${HOST,,}"

# copy certificate generation tool
mkdir -p "$TOOLDIR"
if ! cp -f "$BIN_PATH"/cert_gen/*.jar "$TOOLDIR" ; then
  exit 1
fi
# run certificate generation tool
# generate CA certificate if necessary
cd "$TOOLDIR"
if [ ! -e "$TOOLDIR/output/ca.cacrt" ] ; then
  if ! java -jar "$TOOLDIR/certgen.jar" -batch -dn "C=$C,ST=$ST,L=$L,O=$O,OU=$OU,CN=$CN" -capass "$PASS_CA" -days "$DAYS" ; then
    exit 1
  fi
fi

# copy certificates 
if ! cp -f "$TOOLDIR/output/ca.cacrt" "$CERTDIR/$HOST" ; then
  exit 1
fi

#node index stop to load database
echo loading database ...
cd "$BIN_PATH"
"$NODEPATH/node" @sage/x3-web-server/index.js STOP --dbUnlockAll
if [ $? -eq 5 ]; then
    echo "Incorrect license !"
    echo "Installation failed."
	exit 1
fi 
cd "$TOOLDIR"

echo starting syracuse ...
$SHELL "$SYRACUSE_PATH/servicestart.sh"


# generating server certificate ...
sleep 10
if ! java -jar "$TOOLDIR/certgen.jar" -create -pass "$PASS_SERVER" -capass "$PASS_CA" -days "$DAYS" -cn "$TCP" -port ${syracuse.service.port} -wait 30 "$HOST" ; then
  exit 1
fi

if [ "$X3INSTALL" == "true" ] ; then
	# copy public key for X3 server 
	if [ "$X3DIR" != "" ] ; then
	  # name replacements
	  PEMNAME=`echo $HOST | tr '[$@.]' '_'`
	  echo installation of the certificate in X3 runtime server ...
	  if ! cp -f "$TOOLDIR/output/$PEMNAME.pem" "$X3DIR/keys" ; then
		if ! cp -f "$TOOLDIR/output/$HOST.pem" "$X3DIR/keys/$PEMNAME.pem" ; then
		  exit 1
		fi
	  fi
	fi
fi

if [ "$X3INSTALLWEB" == "true" ] ; then
	# copy public key for X3 WEB Server 
	if [ "$X3DIRWEB" != "" ] ; then
	  # name replacements
	  mkdir -p "$X3DIRWEB"
	  PEMNAME=`echo $HOST | tr '[$@.]' '_'`
	  echo installation of the certificate in X3 webservices server ...
	  if ! cp -f "$TOOLDIR/output/$PEMNAME.pem" "$X3DIRWEB" ; then
		if ! cp -f "$TOOLDIR/output/$HOST.pem" "$X3DIRWEB/$PEMNAME.pem" ; then
		  exit 1
		fi
	  fi
	fi
fi








#!/bin/sh
echo $(date +"%T") : 2 - "Syracuse inits ..."
# Install a nanny process
export BINPATH="${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}"
export NODEPATH="${nodejs.dir.binpath}"

cd "$BINPATH"
"$NODEPATH/node" @sage/x3-web-server/nanny install ${syracuse.service.port} ${syracuse.service.procnumber} ${syracuse.service.webnumber}
 #!/bin/sh

echo $(date +"%T") : 3 - "Syracuse inits ..."
# Install a nanny process
export BINPATH="${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}"
export NODEPATH="${nodejs.dir.binpath}"
PASSPHRASEHEX="${syracuse.certificate.hexserverpassphrase}"

cd "$BINPATH"
"$NODEPATH/node" @sage/x3-web-server/index.js STOP --dbUnlockAll

# Grant rights in config folder - automaticaly created by syracuse
CUSER=${syracuse.service.username}
CGROUP=${syracuse.service.groupname}
if [ "$CUSER" = "" ] ; then
	CUSER=${USER_NAME}
	CGROUP=${GROUP_NAME}
fi
chown -R $CUSER:$CGROUP "${INSTALL_PATH}/syracuse/config"

if [ $? -eq 5 ]; then
    echo "Incorrect license !"
	exit 1
fi 
#!/bin/sh

echo $(date +"%T") : 6 - "Syracuse inits passphrase ..."
PASSPHRASEHEX="${syracuse.certificate.hexserverpassphrase}"

cd "$BINPATH"

# Grant rights in config folder - automaticaly created by syracuse
CUSER=${syracuse.service.username}
CGROUP=${syracuse.service.groupname}
if [ "$CUSER" = "" ] ; then
	CUSER=${USER_NAME}
	CGROUP=${GROUP_NAME}
fi

#passphrase
if [[ $EUID -ne 0 ]]; then
    CUSER=${syracuse.service.username}
    su -c '"${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}passphrasehex.sh" $PASSPHRASEHEX' $CUSER
else
    echo  "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}passphrasehex.sh  $PASSPHRASEHEX" 
    "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}passphrasehex.sh" $PASSPHRASEHEX
fi
#!/bin/sh

# Start Syracuse command line

BINPATH="${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}"
NODEPATH="${nodejs.dir.binpath}"

cd "$BINPATH" 
"$NODEPATH/node" @sage/x3-web-server/nanny

#!/bin/sh

# Install a nanny process
export BINPATH="${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}"
export NODEPATH="${nodejs.dir.binpath}"

cd "$BINPATH"
"$NODEPATH/node" @sage/x3-web-server/nanny remove#!/bin/sh

CUSER=${syracuse.service.username}
CGROUP=${syracuse.service.groupname}

if [ "$CUSER" = "" ] ; then
	CUSER=${USER_NAME}
	CGROUP=${GROUP_NAME}
fi

echo $(date +"%T") : 1 - "Fix node permissions ..."

# Linux fix permissions
chmod 775 "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}${nodejs.dir.binpath}${FILE_SEPARATOR}node"

echo $(date +"%T") : 1 - "Prepare folders ..."
#  SAM 111711 - delete content of streamline cache folder 
# list all cache directory should look like that pattern <cacheDir>/<user> and delete the content of that dir 
UPDATEMODE=${UPDATEMODE}
if [ "$UPDATEMODE" != "true" ]; then
for f in "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}cache${FILE_SEPARATOR}*"
 do
	# remove all content of all folder under cache/user
	rm -rf $f/*
	rm -rf $f/.* # remove file starts with . except "." and ".."

 done
fi
# Linux rel and temp handle
rm -rf "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}rel"
rm -rf "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}rel"
rm -rf "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}temp"

#echo "Create rel directory ..."
#cp -r "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}" "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}rel"
#cp -r "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}rel" "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}"
echo $(date +"%T") : 1 - "Create temp directory ..."
#mv "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}rel" "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}temp" 
mkdir -p "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}temp"

echo $(date +"%T") : 1 - "Fix permissions ..."
chown -R $CUSER:$CGROUP "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}temp"
chmod a+r -R "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}"
chmod ug+w -R "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}"

UPDATEMODE=${UPDATEMODE}
if [ "$UPDATEMODE" != "true" ]; then
	# Linux license handling
	if [ "${syracuse.service.licencepath}" != "" ]; then
	   cp -f "${syracuse.service.licencepath}" "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}temp${FILE_SEPARATOR}license.json"
	fi
fi
echo $(date +"%T") : 1 - "Creating logpath and certificate directory ..."

mkdir -p "${syracuse.dir.logpath}"
chown -R $CUSER:$CGROUP "${syracuse.dir.logpath}"
chmod 775 "${syracuse.dir.logpath}"
echo ==== Syracuse Service Log ==== >"${syracuse.dir.logpath}"/$HOSTNAME.syracuse-service.log
chown $CUSER:$CGROUP "${syracuse.dir.logpath}"/$HOSTNAME.syracuse-service.log
echo ==== Service Log ==== >"${syracuse.dir.logpath}"/$HOSTNAME.service.log
echo ==== Service Agent Log ==== >"${syracuse.dir.logpath}"/$HOSTNAME.agent_service.log
chmod 666 "${syracuse.dir.logpath}"/*.log


mkdir -p "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}cache"
chown -R $CUSER:$CGROUP "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}cache"
chmod 775 "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}cache"

mkdir -p "${syracuse.dir.certs}"
chmod 775 "${syracuse.dir.certs}"
# convert host name to lowercase
HN_NORMAL=`hostname`
HN_LOWER=`echo $HN_NORMAL | tr '[:upper:]' '[:lower:]'` 
mkdir -p "${syracuse.dir.certs}${FILE_SEPARATOR}$HN_LOWER"
chown -R $CUSER:$CGROUP "${syracuse.dir.certs}${FILE_SEPARATOR}$HN_LOWER"
chown -R $CUSER:$CGROUP "${syracuse.dir.certs}${FILE_SEPARATOR}"*
# only user has any access to contents
chmod -R 700 "${syracuse.dir.certs}${FILE_SEPARATOR}$HN_LOWER"
chmod -R 700 "${syracuse.dir.certs}${FILE_SEPARATOR}"*

if [ -d "${syracuse.certificate.certtool}" ]; then
	rm -f "${syracuse.certificate.certtool}/"* > /dev/null 2>&1
fi
if [ -d "${syracuse.certificate.certtool}" ]; then
	cp -f "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}cert_gen/"*.jar "${syracuse.certificate.certtool}"
fi

echo $(date +"%T") : 1 - "Copy agent files ..."
mkdir -p "${syracuse.dir.agent}"
cp -f "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}${nodejs.dir.binpath}/node" "${syracuse.dir.agent}"
cp -f "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}syragent.js" "${syracuse.dir.agent}"
chmod 775 "${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}${nodejs.dir.binpath}/node"

#!/bin/sh

# patching a customer image without the patch system

INSTALL__PATH="${INSTALL_PATH}${FILE_SEPARATOR}syracuse"
CUSER=${syracuse.service.username}
CGROUP=${syracuse.service.groupname}

if [ "$CUSER" = "" ] ; then
        CUSER=${USER_NAME}
        CGROUP=${GROUP_NAME}
fi

if [ $# -ne 1 ] ; then
        echo "Usage: $0 PATH"
        echo "where PATH is the abolute or relative path of a directory"
        echo "containing the new customer image"
        exit 1
fi

if [ ! -e "$1/version.json" ] ; then
        echo "$1 must be a directory contining a customer image"
        exit 1
fi

pushd "$INSTALL__PATH"

if [ -e ${syracuse.dir.binpath} ] ; then
    if [ ! -e ${syracuse.dir.binpath}/nodelocal.js ] ; then
        echo "Missing nodelocal.js in ${syracuse.dir.binpath} directory"
        exit 1
    fi
    rm -rf ${syracuse.dir.binpath}old/
    if ! mv -f ${syracuse.dir.binpath}/ ${syracuse.dir.binpath}old/ ; then
        echo "Cannot move ${syracuse.dir.binpath} to ${syracuse.dir.binpath}old. Please stop all processes which access it"
        exit 1
    fi
fi    
popd
cp -r "$1" "$INSTALL__PATH/${syracuse.dir.binpath}/"
pushd "$INSTALL__PATH"

if ! cp -f ${syracuse.dir.binpath}old/nodelocal.js ${syracuse.dir.binpath}/nodelocal.js ; then
    echo "Missing nodelocal.js in ${syracuse.dir.binpath}old directory"
    exit 1
fi

rm -rf ${syracuse.dir.binpath}old

chmod 775 ${syracuse.dir.binpath}/${nodejs.dir.binpath}/node
rm -rf temp/
rm -rf ${syracuse.dir.binpath}/rel/
rm -rf ${syracuse.dir.binpath}/temp/
#cp -r ${syracuse.dir.binpath}/ temp/
#cp -r temp/ ${syracuse.dir.binpath}/rel/
#mv -f temp/ ${syracuse.dir.binpath}/temp/
mkdir -p ${syracuse.dir.binpath}/temp/

chown -R $CUSER:$CGROUP ${syracuse.dir.binpath}/temp/
chmod a+r -R ${syracuse.dir.binpath}/
chmod ug+w -R ${syracuse.dir.binpath}

cd ${syracuse.dir.binpath}
./${nodejs.dir.binpath}/node @sage/x3-web-server/nanny adjust

# copy agent file
cp -f "syragent.js" "${syracuse.dir.agent}"
cp -f ./${nodejs.dir.binpath}/node "${syracuse.dir.agent}"

popd#!/bin/sh

BIN_PATH="${INSTALL_PATH}/syracuse/${syracuse.dir.binpath}"
NODE_PATH=${nodejs.dir.binpath}
CUSER=${syracuse.service.username}

if [ "$CUSER" = "" ] ; then
        CUSER=${USER_NAME}
        CGROUP=${GROUP_NAME}
fi

if [ $# -ne 1 ] ; then
        echo "Usage: $0 -check      or     $0 PASSPHRASE"
        echo "-check  just check whether certificate, passphrase, generated private key are OK"
        echo "PASSPHRASE  Passphrase for the generated private key for this Syracuse server"
        exit 1
fi

PASSPHRASE=$1

if [ "$PASSPHRASE" = "-check" ] ; then
   PASSPHRASE=""
fi

su -c "cd '$BIN_PATH'; if ! '$NODE_PATH/node' @sage/x3-web-server/nanny.js passphrase '$PASSPHRASE'; then echo Return status \$?; fi" $CUSER
#!/bin/sh

BIN_PATH="${INSTALL_PATH}/syracuse/${syracuse.dir.binpath}"
NODE_PATH=${nodejs.dir.binpath}
CUSER=${syracuse.service.username}

if [ "$CUSER" = "" ] ; then
        CUSER=${USER_NAME}
        CGROUP=${GROUP_NAME}
fi

if [ $# -ne 1 ] ; then
        echo "Usage: $0 -check      or     $0 PASSPHRASE"
        echo "-check  just check whether certificate, passphrase, generated private key are OK"
        echo "PASSPHRASE  Passphrase for the generated private key for this Syracuse server"
        echo "Passphrase must be in hexadecimal mode"
        exit 1
fi

PASSPHRASE=$1

if [ "$PASSPHRASE" = "-check" ] ; then
   PASSPHRASE=""
fi

su -c "cd '$BIN_PATH'; if ! '$NODE_PATH/node' @sage/x3-web-server/nanny.js passphrasehex '$PASSPHRASE'; then echo Return status \$?; fi" $CUSER
#!/bin/sh

# License tool for emergencies
BINPATH="${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}${FILE_SEPARATOR}"
NODEPATH="${nodejs.dir.binpath}"

cd "$BINPATH"
"$NODEPATH/node" @sage/x3-web-server/licdb --command "$0" $*#!/bin/sh
LOGPATH=${syracuse.dir.logpath}
HOSTNAME=${HOST_NAME}
# you need to be root to launch this script !
SERVICE_NAME=`echo "${component.node.name}" | tr -d [:space:] | tr [:upper:] [:lower:]`

echo $(date +"%T") : 4 - Syracuse service creation ...
echo `date +"%Y-%m-%d %T"`      =====Service $SERVICE_NAME creation >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1
cp -f "${INSTALL_PATH}/syracuse/syracuse.service" /etc/systemd/system/sagesyracuse-$SERVICE_NAME.service

systemctl daemon-reload >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1
systemctl enable sagesyracuse-$SERVICE_NAME >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1

#!/bin/sh
LOGPATH=${syracuse.dir.logpath}
HOSTNAME=${HOST_NAME}
# you need to be root to launch this script !
SERVICE_NAME=`echo "${component.node.name}" | tr -d [:space:] | tr [:upper:] [:lower:]`

echo Syracuse service deletion ...
echo `date +"%Y-%m-%d %T"`      =====Service $SERVICE_NAME deletion >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1
systemctl disable sagesyracuse-$SERVICE_NAME >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1
rm -f /etc/systemd/system/sagesyracuse-$SERVICE_NAME.service

systemctl daemon-reload >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1
#!/bin/sh
LOGPATH=${syracuse.dir.logpath}
HOSTNAME=${HOST_NAME}
# you need to be root to launch this script !
SERVICE_NAME=`echo "${component.node.name}" | tr -d [:space:] | tr [:upper:] [:lower:]`

echo $(date +"%T") : 5 - Syracuse service start
echo `date +"%Y-%m-%d %T"`      =====Service $SERVICE_NAME start >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1
systemctl start sagesyracuse-$SERVICE_NAME >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1
sleep 1
#!/bin/sh
LOGPATH=${syracuse.dir.logpath}
HOSTNAME=${HOST_NAME}
# you need to be root to launch this script !
SERVICE_NAME=`echo "${component.node.name}" | tr -d [:space:] | tr [:upper:] [:lower:]`

# Services status 
echo `date +"%Y-%m-%d %T"`      =====Service $SERVICE_NAME status >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1
systemctl status sagesyracuse-$SERVICE_NAME >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1

#!/bin/sh
LOGPATH=${syracuse.dir.logpath}
HOSTNAME=${HOST_NAME}
# you need to be root to launch this script !
SERVICE_NAME=`echo "${component.node.name}" | tr -d [:space:] | tr [:upper:] [:lower:]`

# Syracuse service stop
echo `date +"%Y-%m-%d %T"`      =====Service $SERVICE_NAME stop >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1
systemctl stop sagesyracuse-$SERVICE_NAME >>"$LOGPATH/$HOSTNAME.syracuse-service.log" 2>&1
sleep 1
# ${UNINSTALL_NAME}
[Unit]
StartLimitIntervalSec=0
Description=Sage Syracuse Server - ${component.node.name}
After=network-online.target

[Service]
Restart=always
RestartSec=60
Environment="BINPATH=${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}"
Environment="NODEPATH=${nodejs.dir.binpath}"
Environment="LOGPATH=${syracuse.dir.logpath}"
Environment="HOME=${syracuse.dir.logpath}"
Environment="HOSTNAME=${HOST_NAME}"

ExecStart=/bin/sh -c '"$BINPATH/$NODEPATH/node" @sage/x3-web-server/nanny >> "$LOGPATH/$HOSTNAME.service.log" 2>&1'
ExecStop=/bin/sh -c '"$BINPATH/$NODEPATH/node" @sage/x3-web-server/nanny stop >> "$LOGPATH/$HOSTNAME.service.log" 2>&1'
WorkingDirectory=${INSTALL_PATH}${FILE_SEPARATOR}syracuse${FILE_SEPARATOR}${syracuse.dir.binpath}
User=${syracuse.service.username}

[Install]
WantedBy=multi-user.target graphical.target# ${UNINSTALL_NAME}
[Unit]
StartLimitIntervalSec=0
Description=Sage Syracuse Server Agent - ${component.node.name}
After=network-online.target

[Service]
Restart=always
RestartSec=60
Environment="AGENTPATH=${syracuse.dir.agent}"
Environment="LOGPATH=${syracuse.dir.logpath}"
Environment="HOSTNAME=${HOST_NAME}"

ExecStart=/bin/sh -c '"$AGENTPATH/node" syragent >> "$LOGPATH/$HOSTNAME.agent_service.log" 2>&1'
ExecStop=/bin/sh -c '"$AGENTPATH/node" syragent stop >> "$LOGPATH/$HOSTNAME.agent_service.log" 2>&1'
WorkingDirectory=${syracuse.dir.agent}

[Install]
WantedBy=multi-user.target graphical.target
